+, -, *, /
) operate on
matrices as well as scalars. Lets look at the various binary operations,
for A binop B
:
A
and
B
must be the same, unless either A
or
B
is a 1-by-1 matrix; in this case a
scalar-matrix addition operation is performed.
A
and
B
must be the same, unless either A
or
B
is a 1-by-1 matrix; in this case a
scalar-matrix subtraction operation is performed.
A
must match
the row dimension of B
, unless either A
or
B
is a 1-by-1 matrix; in this case a
scalar-matrix multiplication is performed.
A/B
) can be thought of
as A*inv (B)
. The column dimensions of A
and B
must be the same. Internally right division
is the same as ``left-division'' with the arguments
transposed.
B
is a 1-by-1 matrix; in this case a
matrix-scalar divide occurs.
A
or B
is
a 1-by-1 matrix.
A
or B
is a
1-by-1 matrix.
A\B
, matrix left division is the
solution to the set of equations Ax = B. If B has
several columns, then each column of x is a solution
to A*x[;i] = B[;i]
. The row dimensions of
A
and B
must agree.
B./A
. The row and
column dimensions of A
and B
must agree,
unless either one is a 1-by-1 matrix.
A^B
raises A
to the B
power. When A
is a matrix, and B
is an
integer scalar, the operation is performed by successive
multiplications. When B
is not an integer, then
the operation is performed using A
's eigenvalues
and eigenvectors. The operation is not allowed if
B
is a matrix.
A.^B
raises A
to the
B
power in an element-by-element fashion. Either
A
or B
can be matrix or scalar. If both
A
and B
are matrices, then the row and
column dimensions must agree.
A'
swaps the rows and columns of A.
For a matrix with complex elements a complex conjugate
transpose is performed.
A.'
swaps the rows and
columns of A. The difference between '
and
.'
is only apparent when A
is a complex
matrix; then A.'
does not perform a complex
conjugate transpose.
2./A
is not interpreted as
2. /A
. is smart enough to group the period with
the /
.